<?php
ob_start();
include("connection.php");
include("header.php");
?>


<table width="567" border="0" cellpadding="0" cellspacing="0" >
  <tr>
    <td colspan="3" bgcolor="#FFD8B0"><h3 align="center"> Please login your accound</h3> </td>
  </tr>
  <tr>
    <td width="5" bgcolor="#FFD8B0">&nbsp;</td>
    <td width="420" bgcolor="#FFD8B0"><form name="form1" method="post" action="login.php?action=login">
      <table width="230" height="116" border="1" cellpadding="0" cellspacing="0" align="center" >
    <tr bgcolor="#CC6600">
      <td width="86"><h2>email</h2></td>
      <td width="205"><label>
        <input type="text" name="email" />
        </label>
          <label></label></td>
    </tr>
    <tr bgcolor="#CC6600">
      <td><h3>password</h3></td>
      <td><label>
        <input type="password" name="password" />
      </label></td>
    </tr>
    <tr bgcolor="#CC6600">
      <td colspan="2"><label> </label>
          <div align="center">
            <input type="submit" name="Submit" value="login" />
        </div></td>
    </tr>
  </table>
</form>    </td>
    <td width="142" bgcolor="#FFD8B0">&nbsp;</td>
  </tr>
  <tr>
    <td height="155" bgcolor="#FFD8B0">&nbsp;</td>
    <td bgcolor="#FFD8B0"><div align="left"><a href="userreg.php">Create a new accound</a> </div></td>
    <td bgcolor="#FFD8B0"><div align="center"><a href="passwordget.php">forget your password</a> </div></td>
  </tr>
</table>

<?php
if($_GET['action']=="login")
{
$email=$_POST["email"];
$password=$_POST["password"];
$q=mysql_query("SELECT * FROM users WHERE email='".$email."'")or die(mysql_error());
	if(mysql_num_rows($q))
	{
		$row=mysql_fetch_array($q);
		$db_password=$row['password'];
		if($password==$db_password)
		{
			echo"welcome";
			session_start();
			$_SESSION['user']=$email;
			$_SESSION['userid']=$row['Id'];
			
			header("location:viewevent1.php");
			exit;
		}
		else {
		
		echo"pass is wrong";

			}

		
	}
	else
		{
			echo"email is wrong";

		}
}
include("footer.php");

?>